"""
测试

"""

from openpyxl import load_workbook
import shortuuid

wb = load_workbook('t2.xlsx')
print(wb)

sheet_list = wb.sheetnames
print(sheet_list)

sheet = wb[sheet_list[0]]
print(sheet)
print(sheet['A1'].value)
print(sheet['A1'].column)
print(sheet['A1'].row)
print(sheet.max_column)
print(sheet.max_row)


def gen_user_list(sheet_obj):
    """生成用户对象列表"""

    user_list = []
    for i in range(2, sheet_obj.max_row + 2):
        wx_code = sheet_obj.cell(i, 1).value
        message = sheet_obj.cell(i, 2).value
        if wx_code and message:
            d = {"wx_code": wx_code, "message": message}
            user_list.append(d)

    return user_list


def gen_edit_pyq_auth_user_list(sheet_obj):
    """
    生成修改朋友圈权限用户对象列表
    :param sheet_obj: sheet对象
    :return:
    """

    user_list = []
    for i in range(2, sheet_obj.max_row + 1):
        wx_name = sheet_obj.cell(i, 1).value
        wx_code = sheet_obj.cell(i, 2).value
        dont_let_it = sheet_obj.cell(i, 3).value
        dont_look = sheet_obj.cell(i, 4).value
        if wx_name and wx_code:
            d = {
                "wx_name": wx_name,
                "wx_code": wx_code,
                "dont_let_it": dont_let_it,
                "dont_look": dont_look,
                "uuid": shortuuid.uuid()
            }
            user_list.append(d)

    return user_list


if __name__ == '__main__':
    result = gen_edit_pyq_auth_user_list(sheet_obj=sheet)
    print(result)
